package br.com.Formula;

import java.awt.Dimension;
import java.beans.PropertyVetoException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JInternalFrame;
/*
 * Principal.java
 *
 * Created on 09/02/2011, 08:37:27
 */

/**
 *
 * @author Jayme Augusto Vara
 */
public class Principal extends javax.swing.JFrame {

    CadastrarPiloto cadastrarPiloto;
    CadastrarPneu cadastrarPneu;
    CadastrarEquipe cadastrarEquipe;
    CadastrarTipoParada cadastrarTipoParada;
    CadastrarParada cadastrarParada;
    ExportarARFF exportarARFF;
    ARFFpesquisa exportARFFpe;
    
    /**
     * Creates new form Principal
     */
    public Principal() {
        initComponents();

        //Maximiza o frame para toda a tela
        setExtendedState(Principal.MAXIMIZED_BOTH);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        deskPane = new javax.swing.JDesktopPane();
        jMenuBar1 = new javax.swing.JMenuBar();
        jmbCadastro = new javax.swing.JMenu();
        jmiEquipe = new javax.swing.JMenuItem();
        jmiPiloto = new javax.swing.JMenuItem();
        jmiPneu = new javax.swing.JMenuItem();
        jmiTipoParada = new javax.swing.JMenuItem();
        jmiParada = new javax.swing.JMenuItem();
        jmbExportar = new javax.swing.JMenu();
        jmiARF = new javax.swing.JMenuItem();
        jmiApe = new javax.swing.JMenuItem();
        jmSair = new javax.swing.JMenu();
        jmiSair = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Formula 1");
        setFocusCycleRoot(false);
        setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage("C:/Users/jayme/Documents/NetBeansProjects/SCV/src/imagens/logo.png"));

        deskPane.setBackground(new java.awt.Color(240, 240, 240));
        deskPane.setBorder(new javax.swing.border.MatteBorder(null));
        deskPane.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jMenuBar1.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N

        jmbCadastro.setText("Cadastro");
        jmbCadastro.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N

        jmiEquipe.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiEquipe.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icone/16 x 16/configure.png"))); // NOI18N
        jmiEquipe.setText("Equipe");
        jmiEquipe.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiEquipeActionPerformed(evt);
            }
        });
        jmbCadastro.add(jmiEquipe);

        jmiPiloto.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiPiloto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icone/16 x 16/configure.png"))); // NOI18N
        jmiPiloto.setText("Piloto");
        jmiPiloto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiPilotoActionPerformed(evt);
            }
        });
        jmbCadastro.add(jmiPiloto);

        jmiPneu.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiPneu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icone/16 x 16/carro.png"))); // NOI18N
        jmiPneu.setText("Pneu");
        jmiPneu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiPneuActionPerformed(evt);
            }
        });
        jmbCadastro.add(jmiPneu);

        jmiTipoParada.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiTipoParada.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icone/16 x 16/configure.png"))); // NOI18N
        jmiTipoParada.setText("Tipo da Parada");
        jmiTipoParada.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiTipoParadaActionPerformed(evt);
            }
        });
        jmbCadastro.add(jmiTipoParada);

        jmiParada.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiParada.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icone/16 x 16/configure.png"))); // NOI18N
        jmiParada.setText("Parada");
        jmiParada.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiParadaActionPerformed(evt);
            }
        });
        jmbCadastro.add(jmiParada);

        jMenuBar1.add(jmbCadastro);

        jmbExportar.setText("Exportar");
        jmbExportar.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N

        jmiARF.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiARF.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icone/16 x 16/add.png"))); // NOI18N
        jmiARF.setText("Arquivo ARF");
        jmiARF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiARFActionPerformed(evt);
            }
        });
        jmbExportar.add(jmiARF);

        jmiApe.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiApe.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icone/16 x 16/relatorio.png"))); // NOI18N
        jmiApe.setText("ARF pesquisa");
        jmiApe.setName("");
        jmiApe.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiApeActionPerformed(evt);
            }
        });
        jmbExportar.add(jmiApe);

        jMenuBar1.add(jmbExportar);

        jmSair.setText("Sair");
        jmSair.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N

        jmiSair.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
        jmiSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icone/16 x 16/exit.png"))); // NOI18N
        jmiSair.setText("Sair");
        jmiSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiSairActionPerformed(evt);
            }
        });
        jmSair.add(jmiSair);

        jMenuBar1.add(jmSair);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(deskPane, javax.swing.GroupLayout.DEFAULT_SIZE, 619, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(deskPane, javax.swing.GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void criarJanelaInterna(JInternalFrame internalframe) {
        //Adiciona o InternalFrame no DesktopPane
        deskPane.add(internalframe);
        //Calcula o espaço do DesktopPane para centralizar o InternalFrame
        Dimension d = internalframe.getDesktopPane().getSize();
        internalframe.setLocation((d.width - internalframe.getSize().width) / 2,
                (d.height - internalframe.getSize().height) / 2);
        //Exibe o InternalFrame
        try {
            internalframe.setSelected(true);
            internalframe.setVisible(true);
        } catch (PropertyVetoException ex) {
            Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void jmiSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiSairActionPerformed
        //Finaliza a aplicação
        System.exit(0);
    }//GEN-LAST:event_jmiSairActionPerformed

    private void jmiPneuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiPneuActionPerformed
        //Cria o jinternal frame e o abre
        cadastrarPneu = new CadastrarPneu();
        criarJanelaInterna(cadastrarPneu);
    }//GEN-LAST:event_jmiPneuActionPerformed

    private void jmiTipoParadaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiTipoParadaActionPerformed
        //Cria o jinternal frame e o abre
        cadastrarTipoParada = new CadastrarTipoParada();
        criarJanelaInterna(cadastrarTipoParada);
    }//GEN-LAST:event_jmiTipoParadaActionPerformed

    private void jmiARFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiARFActionPerformed
        //Cria o jinternal frame e o abre
        exportarARFF = new ExportarARFF();
        criarJanelaInterna(exportarARFF);
    }//GEN-LAST:event_jmiARFActionPerformed

    private void jmiParadaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiParadaActionPerformed
        //Cria o jinternal frame e o abre
        cadastrarParada = new CadastrarParada();
        criarJanelaInterna(cadastrarParada);
    }//GEN-LAST:event_jmiParadaActionPerformed

    private void jmiEquipeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiEquipeActionPerformed
        //Cria o jinternal frame e o abre
        cadastrarEquipe = new CadastrarEquipe();
        criarJanelaInterna(cadastrarEquipe);
    }//GEN-LAST:event_jmiEquipeActionPerformed

    private void jmiPilotoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiPilotoActionPerformed
        //Cria o jinternal frame e o abre
        cadastrarPiloto = new CadastrarPiloto();
        criarJanelaInterna(cadastrarPiloto);
    }//GEN-LAST:event_jmiPilotoActionPerformed

    private void jmiApeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiApeActionPerformed
        //Cria o jinternal frame e o abre
        exportARFFpe = new ARFFpesquisa();
        criarJanelaInterna(exportARFFpe);
    }//GEN-LAST:event_jmiApeActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Principal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane deskPane;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenu jmSair;
    private javax.swing.JMenu jmbCadastro;
    private javax.swing.JMenu jmbExportar;
    private javax.swing.JMenuItem jmiARF;
    private javax.swing.JMenuItem jmiApe;
    private javax.swing.JMenuItem jmiEquipe;
    private javax.swing.JMenuItem jmiParada;
    private javax.swing.JMenuItem jmiPiloto;
    private javax.swing.JMenuItem jmiPneu;
    private javax.swing.JMenuItem jmiSair;
    private javax.swing.JMenuItem jmiTipoParada;
    // End of variables declaration//GEN-END:variables
}
